/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vzone.job;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import vzone.structs.BasePeople;
import vzone.structs.Job;
import vzone.structs.OperatorCode;
import vzone.tools.SqlHelper;

/**
 *
 * @author Kingpro
 */
public class Jobs implements IJob
{
    private static final  String GETJOBBYID_S="SELECT * FROM [j_job] WHERE [jobId]=?";
    private static Jobs jobs=new Jobs();
    public static Jobs getJobs()
    {
	return jobs;
    }

    @Override
    public List<Job> ListJob()
    {
	throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public OperatorCode ApplyForJob(BasePeople people, Job job)
    {
	throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public OperatorCode Resignation(BasePeople people)
    {
	throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public OperatorCode GetJobInfo(UUID jobId, Job job)
    {
	try
	{
	    if(jobId==null)
	    {
		return OperatorCode.OTHER_ERROR;
	    }
	    ArrayList<Object> result = SqlHelper.ExecuteReader(SqlHelper.getConnect(), GETJOBBYID_S, new Object[]{jobId.toString()});
	    if(result.size()==0)
	    {
		return OperatorCode.OTHER_ERROR;
	    }
	    Object[] resulta=(Object[])result.get(0);
	    job.JobIDUuid=jobId;
	    job.JobNameS=(String)resulta[1];
	    job.JobDescriptionS=(String)resulta[2];
	    job.CompanyIDUuid=UUID.nameUUIDFromBytes((byte[])resulta[3]);
	    job.PayD=Double.parseDouble(resulta[4].toString());
	    job.StartTimePerDay=Integer.parseInt(resulta[6].toString());
	    job.EndTimePerDay=Integer.parseInt(resulta[7].toString());
	    return OperatorCode.SUCCESS;
	}
	catch (Exception ex)
	{
	    return OperatorCode.SQLERROR;
	}
    }

}
